<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>VUE起步</title>
        <script type="text/javascript" src="https://unpkg.com/vue/dist/vue.js"></script>
    </head>
    <body>
        <div id="app">
            <p>{{message}}</p>
            <p>{{sayHello()}}</p>
        </div>
        <div>
            <button onclick="showVueEl();">显示Vue对象所在的DOM元素</button>
            <button onclick="showVueData();">显示Vue对象data属性的message值</button>
            <button onclick="execVueMethod();">调用Vue对象的sayHello方法</button>
            <button onclick="changeMessage();">修改Vue对象data属性的message值</button>
        </div>
    </body>
    <script type="text/javascript">
        var vueObj = new Vue({
            el: '#app',
            data: {
                message: '你好，我是消息详情！'
            },
            methods: {
                sayHello: function() {
                    return "Hello!";
                }
            }
        });

        function showVueEl() {
            console.log(vueObj.$el);
        }

        function showVueData() {
            alert(vueObj.$data.message);
        }

        function execVueMethod() {
            alert(vueObj.sayHello());
        }

        function changeMessage() {
            vueObj.$data.message = "该条消息被我修改了";
        }
    </script>
</html>